<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客管理 - Lumina AI 内容管理后台</title>
    <script src="../../frontend/assets/js/tailwindcss.js"></script>
    <script>
        tailwind = window.tailwind || {};
        tailwind.config = {
            theme: {
                extend: {
                    colors: { primary: '#FFE45C', secondary: '#FFE45C', accent: '#10B981' },
                    borderRadius: { '2xl': '20px', '3xl': '24px' }
                }
            }
        };
    </script>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="../../frontend/assets/css/font-awesome.min.css" rel="stylesheet">
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
        body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
        /* Sticky columns and horizontal scroll */
        .table-scroll { overflow-x: auto; }
        .admin-table { min-width: 1400px; }
        .admin-table th, .admin-table td { white-space: nowrap; background: #ffffff; }
        .sticky-col { position: sticky; z-index: 10; }
        thead .sticky-col { z-index: 20; }
        .sticky-left { left: 0; box-shadow: inset -8px 0 8px -8px rgba(0,0,0,0.08); }
        .sticky-right { right: 0; box-shadow: inset 8px 0 8px -8px rgba(0,0,0,0.08); }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Header -->
    <header class="bg-white/95 backdrop-blur-md shadow-sm border-b border-gray-100 fixed top-0 left-0 right-0 z-40">
        <div class="flex items-center justify-between px-6 py-4">
            <div class="flex items-center">
                <button id="sidebarToggle" class="text-gray-500 hover:text-gray-700 mr-4">
                    <i class="fas fa-bars text-xl"></i>
                </button>
                <div class="flex items-center">
                    <div class="w-8 h-8 bg-gradient-to-r from-yellow-400 to-yellow-500 rounded-lg flex items-center justify-center mr-3">
                        <i class="fas fa-brain text-white text-sm"></i>
                    </div>
                    <h1 class="text-xl font-bold text-gray-800">Lumina AI 内容管理后台</h1>
                </div>
            </div>
            
            <div class="flex items-center space-x-4">
                <a href="../index.html" class="text-gray-500 hover:text-gray-700 transition-colors">
                    <i class="fas fa-arrow-left mr-2"></i>返回仪表盘
                </a>
                <div class="text-sm text-gray-600">
                    <i class="fas fa-user mr-2"></i>
                    <span id="currentUsername">加载中...</span>
                </div>
                <button onclick="authManager.logout()" class="text-gray-500 hover:text-red-600 transition-colors">
                    <i class="fas fa-sign-out-alt mr-2"></i>退出
                </button>
            </div>
        </div>
    </header>

    <!-- Sidebar -->
    <aside id="sidebar" class="fixed left-0 top-16 h-full w-64 bg-white shadow-lg z-30">
        <nav class="p-6">
            <ul class="space-y-2">
                <li>
                    <a href="/admin/index.html" class="flex items-center px-4 py-3 text-gray-700 hover:text-yellow-700 hover:bg-yellow-50 rounded-lg transition-colors">
                        <i class="fas fa-tachometer-alt mr-3"></i>
                        仪表盘
                    </a>
                </li>
                <li>
                    <a href="/admin/blog/list.html" class="flex items-center px-4 py-3 text-yellow-700 bg-yellow-50 rounded-lg font-medium">
                        <i class="fas fa-blog mr-3"></i>
                        博客管理
                    </a>
                </li>
                <li>
                    <a href="#" class="flex items-center px-4 py-3 text-gray-400 cursor-not-allowed opacity-50">
                        <i class="fas fa-book mr-3"></i>
                        词条管理
                        <span class="ml-auto text-xs bg-gray-200 text-gray-600 px-2 py-1 rounded">v2.0</span>
                    </a>
                </li>
                <li>
                    <a href="#" class="flex items-center px-4 py-3 text-gray-400 cursor-not-allowed opacity-50">
                        <i class="fas fa-lightbulb mr-3"></i>
                        指令库管理
                        <span class="ml-auto text-xs bg-gray-200 text-gray-600 px-2 py-1 rounded">v2.0</span>
                    </a>
                </li>
                <li>
                    <a href="#" class="flex items-center px-4 py-3 text-gray-400 cursor-not-allowed opacity-50">
                        <i class="fas fa-cog mr-3"></i>
                        系统设置
                        <span class="ml-auto text-xs bg-gray-200 text-gray-600 px-2 py-1 rounded">v2.0</span>
                    </a>
                </li>
            </ul>
        </nav>
    </aside>

    <!-- Main Content -->
    <main id="mainContent" class="ml-64 pt-20 p-6 bg-gray-50 min-h-screen">
        <!-- Page Header -->
        <div class="flex items-center justify-between mb-6">
            <div>
                <h2 class="text-2xl font-bold text-gray-800">博客管理</h2>
                <p class="text-gray-600">管理您的博客内容，支持创建、编辑、删除和查看</p>
            </div>
            <a href="/admin/blog/edit.html" class="bg-yellow-500 hover:bg-yellow-600 text-white px-6 py-3 rounded-xl font-medium transition-colors">
                <i class="fas fa-plus mr-2"></i>新建博客
            </a>
        </div>

        <!-- Filters and Search -->
        <div class="bg-white rounded-2xl shadow-sm p-6 mb-6 border border-gray-100">
            <div class="flex flex-col md:flex-row gap-4">
                <div class="flex-1">
                    <label class="block text-sm font-medium text-gray-700 mb-2">关键词搜索</label>
                    <div class="relative">
                        <input 
                            type="text" 
                            id="searchInput" 
                            placeholder="搜索博客标题、摘要、分类、作者或标签..."
                            class="w-full pl-10 pr-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-yellow-500"
                        >
                        <i class="fas fa-search absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"></i>
                    </div>
                </div>
                <div class="flex items-end">
                    <button id="searchBtn" class="bg-yellow-500 hover:bg-yellow-600 text-white px-6 py-2 rounded-lg transition-colors">
                        <i class="fas fa-search mr-2"></i>搜索
                    </button>
                </div>
            </div>
        </div>

        <!-- Blog List -->
        <div class="bg-white rounded-2xl shadow-sm border border-gray-100">
            <div class="table-scroll">
                <table class="w-full admin-table">
                    <thead class="bg-gray-50 border-b border-gray-200">
                        <tr>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider sticky-col sticky-left">ID</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">标题</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">摘要</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">内容文件</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">分类</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">标签</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">作者</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">作者职称</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">发布日期</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider sticky-col sticky-right">操作</th>
                        </tr>
                    </thead>
                    <tbody id="blogTableBody" class="bg-white divide-y divide-gray-200">
                        <tr>
                            <td colspan="10" class="px-6 py-12 text-center text-gray-500">
                                <i class="fa-solid fa-spinner fa-spin text-2xl mb-3"></i>
                                <p>正在加载博客数据...</p>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>

        <!-- Pagination -->
        <div class="mt-6 flex items-center justify-between">
            <div class="text-sm text-gray-700">
                显示 <span id="startIndex">0</span> 到 <span id="endIndex">0</span> 条，共 <span id="totalCount">0</span> 条
            </div>
            <div class="flex space-x-2" id="pagination">
                <!-- 分页按钮将通过 JavaScript 动态生成 -->
            </div>
        </div>
    </main>

    <!-- Delete Confirmation Modal -->
    <div id="deleteModal" class="fixed inset-0 bg-black bg-opacity-50 hidden items-center justify-center z-50">
        <div class="bg-white rounded-lg p-6 max-w-sm mx-4">
            <div class="flex items-center mb-4">
                <i class="fas fa-exclamation-triangle text-red-500 text-xl mr-3"></i>
                <h3 class="text-lg font-medium text-gray-900">确认删除</h3>
            </div>
            <p class="text-gray-600 mb-6">确定要删除这篇博客吗？此操作不可恢复。</p>
            <div class="flex space-x-3">
                <button onclick="closeDeleteModal()" class="flex-1 bg-gray-300 text-gray-700 py-2 px-4 rounded-lg hover:bg-gray-400 transition-colors">
                    取消
                </button>
                <button id="confirmDeleteBtn" class="flex-1 bg-red-500 text-white py-2 px-4 rounded-lg hover:bg-red-600 transition-colors">
                    确定删除
                </button>
            </div>
        </div>
    </div>

    <script src="../js/auth.js"></script>
    <script src="../js/common.js"></script>
    <script src="js/blog-list.js"></script>
</body>
</html>
